package com.uday.kraterchat.chatclient.command
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.uday.kraterchat.chatclient.business.UserServiceDelegate;
	import com.uday.kraterchat.chatclient.control.RegisterUserEvent;
	import com.uday.kraterchat.chatclient.model.ChatClientModel;
	
	import mx.rpc.IResponder;
	import mx.rpc.events.ResultEvent;

	public class RegisterUserCommand implements ICommand, IResponder
	{
		private var objChatClientModelLocator:ChatClientModel = ChatClientModel.getInstance();
		
		public function RegisterUserCommand()
		{
			//TODO: implement function
		}

		public function execute(event:CairngormEvent):void
		{
			var objLoginUserDel:UserServiceDelegate = new UserServiceDelegate(this);
			objLoginUserDel.registerNewUser((event as RegisterUserEvent).objUserInfoItem);
		}
		
		public function result(data:Object):void
		{
			if((data as ResultEvent).result){
				objChatClientModelLocator.mainAppState = KraterChatAir.STATE_LOGIN;
			}
		}
		
		public function fault(info:Object):void
		{
			//TODO: implement function
		}
		
	}
}